Skip to content

perf: project imported matches to slim structs in standings import#7654

Open
Rathoz wants to merge 1 commit into
mainfrom
standings-import-slim-match
Open

perf: project imported matches to slim structs in standings import#7654
Rathoz wants to merge 1 commit into
mainfrom
standings-import-slim-match

Conversation

@Rathoz

@Rathoz Rathoz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Imported matches are now projected to a StandingsImportMatch struct — {matchId, finished, winner, opponents (by ref), slim games} — at import time in Parse/Lpdb.lua. Tiebreakers (Buchholz, Game/Util, Game/Rounds/Util) are the only consumers and read exactly these fields. This drops bracketData, extradata, and full game payloads per match (big memory win on large group stages), and matchFromRecord now runs once per match2 record instead of once per (match, round).
  • mergeOpponentsData in Table.lua now uses a name-keyed opponent index (O(1) fast path, one linear-scan fallback for renamed teams via Opponent.same) and an explicit allocation-safe merge that reproduces deepMerge's output without mutating imported structures. The Table module import is removed as it is no longer needed.
  • Type annotations updated: TiebreakerOpponent.matches and StandingTableOpponentData.rounds.match/matches now reference StandingsImportMatch instead of MatchGroupUtilMatch.

How did you test this change?

  • busted --run=ci: 605 successes / 0 failures / 0 errors (standings_import_spec, standings_table_merge_spec, standings_tiebreaker_spec all pass)
  • luacheck on all three touched files: 0 warnings / 0 errors
  • Based on standings-tests-ai (PR test: add integration tests for standings #7647) whose import/merge/tiebreaker specs lock the observable semantics; no test files were modified.

🤖 Generated with Claude Code

@Rathoz Rathoz requested review from a team as code owners June 12, 2026 15:59
@Rathoz Rathoz force-pushed the standings-import-slim-match branch from 1751355 to 29e107e Compare June 12, 2026 16:11

@hjpalpha hjpalpha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems reasonable on phone

Base automatically changed from standings-tests-ai to main July 2, 2026 09:51
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 09:55
@Rathoz Rathoz force-pushed the standings-import-slim-match branch from 29e107e to 1fc9c87 Compare July 2, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors standings match importing to project LPDB match2 records into a slimmer StandingsImportMatch shape at import time, reducing memory usage and avoiding repeated matchFromRecord conversions while keeping tiebreaker behavior unchanged.

Changes:

  • Project imported matches into StandingsImportMatch (only fields consumed by standings/tiebreakers) during LPDB import.
  • Replace Table.deepMerge usage in StandingsTable.mergeOpponentsData with an allocation-safe merge and a name-keyed fast lookup (with Opponent.same fallback).
  • Update type annotations so standings/tiebreakers reference StandingsImportMatch instead of MatchGroupUtilMatch.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lua/wikis/commons/Standings/Tiebreaker/Interface.lua Updates tiebreaker opponent match type to the new slim match struct.
lua/wikis/commons/Standings/Table.lua Removes Table.deepMerge dependency and implements a faster, non-mutating merge for manual/imported opponent data.
lua/wikis/commons/Standings/Parse/Lpdb.lua Introduces StandingsImportMatch and constructs it once per LPDB record before per-round parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 32 to 35
---@class StandingTableOpponentData
---@field rounds {tiebreakerPoints: number?, specialstatus: string, scoreboard: Scoreboard?,
---match: MatchGroupUtilMatch?, matches: MatchGroupUtilMatch[], matchId: string}[]?
---match: StandingsImportMatch?, matches: StandingsImportMatch[], matchId: string}[]?
---@field opponent standardOpponent
Comment on lines 136 to +141
---@param roundNumber integer
---@param match match2
---@param slimMatch StandingsImportMatch
---@param opponents StandingTableOpponentData[]
---@param scoreMapper fun(opponent: standardOpponent): number?
---@param maxRounds integer
function StandingsParseLpdb.parseMatch(roundNumber, match, opponents, scoreMapper, maxRounds)
local match2 = MatchGroupUtil.matchFromRecord(match)
Array.forEach(match2.opponents, function(opponent)
function StandingsParseLpdb.parseMatch(roundNumber, slimMatch, opponents, scoreMapper, maxRounds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants